<?php echo $this->Html->css('postBox');?> 
<form id="send" onsubmit="return false;">
	<input type="hidden" value="<?php echo $data['User']['id'];?>" id="toUserId"/>
	<div id="userInfo">
		<span>发送给：</span><img id="userHead" src="<?php echo $data['User']['url'];?>"/><span><?php echo $data['User']['username']?></span>
	</div>
	<textarea id="sendContent" placeholder="请输入信息"></textarea><br />
	<button id="sendButton">发送</button>
</form>
<script>
	$(document).ready(function(){
		$("#sendButton").click(function(){
			var sendContent = $("#sendContent").val();
			if (sendContent.length == 0) {
				alert("还没有写信息呢！");
				return;
			}
			var userId = $("#toUserId").val();

			$.post("<?php echo $this->Html->url(array('controller'=>'messages','action'=>'post')); ?>/"+userId,
				{'data[Message][content]':sendContent},
				function(data){
					data = JSON.parse(data);
					if (data['result'] == true){
						alert('发送成功。');
						// $("#sendContent").val("");
						window.close(); 
					}
					else{
						alert('发送失败。');
					}
				}
			)

		})
	})
</script>